package top.houry.redis.config;

import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.connection.MessageListener;
import org.springframework.stereotype.Component;

import java.io.UnsupportedEncodingException;

/**
 * @Desc
 * @Author houruiyang
 * @Date 2023/2/22
 **/
public class MyARedisChannelListener implements MessageListener {
    @Override
    public void onMessage(Message message, byte[] pattern) {
        byte[] channel = message.getChannel();
        byte[] body = message.getBody();

        try {
            String content = new String(body,"UTF-8");
            String address = new String(channel,"UTF-8");
            System.out.println("a redis get " + content + " from " + address);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
    }



}
